<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%> 
<%@ include file="../layout/_header.jsp"%>
<body style="padding: 10px; height: 100%; text-align: center;">
	<ipnut type="hidden" id="MenuNo" value="BaseManageEmployees" />
	<div id="mainsearch" style="width: 98%">
		<div class="searchtitle">
			<span>搜索</span><img src="../lib/icons/32X32/searchtool.gif" />
			<div class="togglebtn"></div>
		</div>
		<div class="navline" style="margin-bottom: 4px; margin-top: 4px;"></div>
		<div class="searchbox">
			<form id="formsearch" class="l-form"></form>
		</div>
	</div>
	<div id="maingrid"></div>
	<script type="text/javascript">
      //相对路径
      var rootPath = "../";
      //列表结构
      var grid = $("#maingrid").ligerGrid({
          columns: [
                    { display: "序号", name: "id", width: 120 },  
                    { display: "部门", name: "deptname", width: 120 },  
                    { display: "行政职务", name: "duty", width: 120 },  
                    { display: "姓名", name: "name", width: 80 },  
                    { display: "性别", name: "gender", width: 80 }, 
                    { display: "出生日期", name: "birthday", type: "date", width: 80 }, 
                    { display: "年龄", name: "age", width: 80 }, 
                    { display: "参加工作时间", name: "beginWorkTime",type: "date", width: 80 }, 
                    { display: "学历", name: "career", width: 80 }, 
                    { display: "毕业院校", name: "college", width: 120 }, 
                    { display: "所学专业", name: "major", width: 120 }, 
                    { display: "毕业时间", name: "graduationDate",  format: 'yyyy-MM-dd', type: 'date', width: 80 }, 
                    { display: "政治面貌", name: "politicalStatus", width: 80 }
                   ], 
                   dataAction: 'server',
                   usePager: true,       //服务器分页
                   pageSize:20,
                   pageParmName:'page.currentPage',
                   pagesizeParmName:'page.pagesize',
                   toolbar: {},
          url: rootPath + 'actions/grid/Grid.action?view=searchEmployee', sortName: 'id', 
          width: '98%', height: '100%',heightDiff:-10, checkbox: false
      });

      //双击事件
      LG.setGridDoubleClick(grid, 'modify');

      //搜索表单应用ligerui样式
      $("#formsearch").ligerForm({
		   fields:[
		   {display:"姓氏",name:"lastName",newline:false,labelWidth:100,width:220,space:30,type:"text",cssClass:"field"}, 
		   { display: "出生日期 大于", name: "BirthDate", newline: false, labelWidth: 100, width: 220, space: 30, type: "date", cssClass: "field", 
			          attr: { "op": "greater"}
		   }],
		   toJSON: JSON2.stringify
	  });

      //增加搜索按钮,并创建事件
      LG.appendSearchButtons("#formsearch", grid);

      //加载toolbar
      LG.loadToolbar(grid, toolbarBtnItemClick);

      //工具条事件
      function toolbarBtnItemClick(item) {
          switch (item.id) {
              case "add":
                  top.f_addTab(null, '增加员工信息', '../actions/Employee.action?newEmployeeForm');
                  break;
              case "view":
                  var selected = grid.getSelected();
                  if (!selected) { LG.tip('请选择行!'); return }
                  top.f_addTab(null, '查看员工信息', '../actions/Employee.action?viewEmployeeForm&employee.id='+selected.id);
                  break;
              case "modify":
                  var selected = grid.getSelected();
                  if (!selected) { LG.tip('请选择行!'); return }
                  top.f_addTab(null, '修改员工信息', '../actions/Employee.action?editEmployeeForm&employee.id='+selected.id);
                  break;
              case "delete":
                  jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
                      if (confirm)
                          f_delete();
                  });
                  break;
          }
      }
      function f_reload() {
          grid.loadData();
      }
      function f_delete() {
          var selected = grid.getSelected();
          if (selected) {
              LG.ajax({
                  type: 'actions/Employee.action',
                  method: 'removeEmployee',
                  loading: '正在删除中...',
                  data: { id: selected.id },
                  success: function () {
                      LG.showSuccess('删除成功');
                      f_reload();
                  },
                  error: function (message) {
                      LG.showError(message);
                  }
              });
          }
          else {
              LG.tip('请选择行!');
          }
      }
  </script>
<%@ include file="../layout/_footer.jsp"%>